﻿using Dapper;
using GLstudent.Models;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace GLstudent.DAL
{
    public class DAL_denglu
    {
        MySqlConnection mySqlConnection = new MySqlConnection(ConfigHelper.Configuration["MySQLConnectionString"]);
        /// <summary>
        /// 登录的方法
        /// </summary>
        public denglu Select(denglu yonghu)
        {
            var chaxun = mySqlConnection.QueryFirstOrDefault<denglu>
            ("SELECT * FROM denglu WHERE yonghu = @yonghu AND `mima`= @mima", yonghu);
            return chaxun;
        }
        /// <summary>
        /// 注册教师用户的方法
        /// </summary>
        /// <param name="zengjia">与denglu对应类的参数</param>
        /// <returns></returns>
        public int TInsert(denglu zengjia)
        {
            var sql = "insert into denglu (yonghu,mima,t_bianhao,guanlizhe) values (@yonghu,@mima,@t_bianhao,@guanlizhe)";
            MySqlConnection mySqlConnection = new MySqlConnection
            (ConfigHelper.Configuration["MySQLConnectionString"]);
            var zengjia1 = mySqlConnection.Execute(sql, zengjia);
            return zengjia1;
        }
        /// <summary>
        /// 注册学生用户的方法
        /// </summary>
        /// <param name="zengjia">与denglu类对应的参数</param>
        /// <returns></returns>
        public int SInsert(denglu zengjia)
        {
            var sql = "insert into denglu (yonghu,mima,s_xuehao) values (@yonghu,@mima,@s_xuehao)";
            MySqlConnection mySqlConnection = new MySqlConnection
            (ConfigHelper.Configuration["MySQLConnectionString"]);
            var zengjia1 = mySqlConnection.Execute(sql, zengjia);
            return zengjia1;
        }
    }
}
